using System.Collections.Generic;
using System.ServiceProcess;
using System.Xml;
using NUnit.Framework;
using SharpService.Container;
using SharpService.Test;

namespace SharpService.UnitTests
{
    [TestFixture]
    public class ServiceParsing
    {
        [Test]
        public void ParseEmptyXml()
        {
            XmlDocument doc = new XmlDocument();

            List<ServiceBase> services = Program.ParseServices(doc.CreateNavigator());
            Assert.AreEqual(0, services.Count);
        }

        [Test]
        public void ParseBaseService()
        {
            XmlDocument doc = new XmlDocument();
            XmlElement services = doc.CreateElement("services");
            doc.AppendChild(services);
            XmlElement service = doc.CreateElement("service");
            service.SetAttribute("type", typeof (DebugService) + ", SharpService.Test");
            services.AppendChild(service);
            List<ServiceBase> parsed = Program.ParseServices(doc.CreateNavigator());
            Assert.AreEqual(1, parsed.Count);
            Assert.AreEqual(typeof (DebugService), parsed[0].GetType());
        }
    }
}